package run.theo.mallproducts.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import run.theo.mallcommons.entity.Product;
import run.theo.mallproducts.service.ProductService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author theo
 * @since 2022/10/16 14:00
 */
@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {
    @Autowired
    private ProductService productService;

    //商品信息查询
    @GetMapping("/{pid}")
    public Product product(@PathVariable("pid") Integer pid){
        log.info("查询{}号商品信息",pid);
        Product product = productService.getById(pid);
        log.info("商品查询成功，内容为{}",product);
        return product;
    }
}
